package com.zn.opit.websocketdemo.controller;

import com.zn.opit.websocketdemo.domain.R;
import com.zn.opit.websocketdemo.domain.ws.WsMsgVO;
import com.zn.opit.websocketdemo.service.RecycleCustomerService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/ws")
@RestController
@RequiredArgsConstructor(onConstructor =@__(@Autowired))
public class WsController {

    private final RecycleCustomerService recycleCustomerService;

    @GetMapping("/test")
    public R test() {
        WsMsgVO msgVO = new WsMsgVO();
        msgVO.setType("warning");
        msgVO.setMsg("电压过高");
        recycleCustomerService.sendMsg(msgVO);
        return R.ok();
    }
}
